#include <stdio.h>

#include <algorithm>
#include <string>

using namespace std;

void Solve(int n) {
  for (int x = 10000; x <= 999999; ++x) {
    char buf[20];
    sprintf(buf, "%d", x);
    string a(buf), b(buf);
    reverse(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < a.length(); ++i) {
      ans += a[i] - '0';
    }
    if (ans == n && a == b) {
      printf("%d\n", x);
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  Solve(n);
  return 0;
}